package com.yiqi.lottery.feature.lottery.view.adapter;

import android.text.Html;
import android.text.TextUtils;
import android.widget.TextView;

import butterknife.BindView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yiqi.lottery.R;
import com.yiqi.lottery.common.util.DateTool;
import com.yiqi.lottery.entity.bo.BaseBo;
import com.yiqi.lottery.entity.bo.BetPlanBo;
import com.yiqi.lottery.entity.bo.CouprceBo;

public class TableAdpter extends BaseQuickAdapter<BetPlanBo, BaseViewHolder> {

    private int mType;

    public TableAdpter() {
        super(R.layout.item_lottery_hall_result);
    }


    @Override
    protected void convert(BaseViewHolder helper, BetPlanBo item) {

        try {
            String str = "";
            String result = "";
            for (int i = 0; i < item.getBet_list().size(); i++) {
                str += item.getBet_list().get(i).getBet() + "&nbsp;&nbsp;" + "<font color=\"#d83220\">"
                        + (TextUtils.isEmpty(item.getBet_list().get(i).getRadio()) ? "" : "(" + item.getBet_list().get(i).getRadio() + ")")
                        + "</font>" + "<br/><br/>";
                result += TextUtils.isEmpty(item.getBet_list().get(i).getResult()) ? "未知\n\n" : item.getBet_list().get(i).getResult() + "\n\n";
            }

            String teamsStr = "";

            if (mType == 5) {
                teamsStr = item.getAn() + "<br /><font color=\"#d83220\">VS</font><br/>" + item.getHn();
            } else {
                teamsStr = item.getHn() + "<br /><font color=\"#d83220\">VS</font><br/>" + item.getAn();
            }


            helper.setText(R.id.tv_hall_table_date, DateTool.getWeek(item.getOt()) + "\t" + (TextUtils.isEmpty(item.getIssue_id()) ? "" : item.getIssue_id().substring(item.getIssue_id().length() - 3, item.getIssue_id().length())))
                    .setText(R.id.tv_hall_table_time, DateTool.TimeStampYE(item.getOt()) + "\n" + DateTool.TimeStampFM(item.getOt()))
                    .setText(R.id.tv_hall_table_vs, Html.fromHtml(teamsStr))
                    .setText(R.id.tv_hall_table_item, Html.fromHtml(str))
                    .setText(R.id.tv_hall_table_result, result)
                    .setText(R.id.tv_hall_table_dan, item.getDan() + "")
            ;
        } catch (Exception e) {

        }

    }

    public int getmType() {
        return mType;
    }

    public void setmType(int mType) {
        this.mType = mType;
        notifyDataSetChanged();
    }
}
